﻿using parkMonitor.language;
using parkMonitor.model;
using parkMonitor.viewModel.alarm;
using parkMonitor.viewModel.devInfoPanel;
using parkMonitor.viewModel.objectTree;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace parkMonitor.viewModel {
	/// <summary>设计ViewModel</summary>
	class DesignMainWinVM : MainWinVM {

		public DesignMainWinVM() {
			DeviceType[] arrType = new DeviceType[] {
				DeviceType.NumMachine, DeviceType.Laser, DeviceType.Tray,
				DeviceType.Robot, DeviceType.Raster, DeviceType.Ultrasonic, DeviceType.Car, DeviceType.OrtherObject
			};

			//		name		info		status			name1			info1		status1
			string[] testData = new string[] {
				"号牌机1",		"正常",		"Normal",		"号牌机2",		"正常",		"Normal",
				//"激光1",		"正常",		"Offline",		"激光2",		"正常",		"Offline",
				//"托盘1",		"正常",		"Warning",		"托盘2",		"正常",		"Warning",
				//"机械抓手1",	"正常",		"Error",		"机械抓手2",	"正常",		"Error",
				//"光栅1",		"正常",		"Normal",		"光栅2",		"正常",		"Normal",
				//"超声波1",		"正常",		"Normal",		"超声波2",		"正常",		"Normal",
				//"传感器1",      "正常",		"Normal",       "传感器2",		"正常",		"Normal",
				//"车辆1",		"正常",     "Normal",		"车辆2",		"正常",     "Error",
				//"其他物体1",	"正常",		"None",			"其他物体2",	"正常",		"None",
			};

			const int oneItemCount = 6;
			for(int i = 0; i < testData.Length; i += oneItemCount) {
				LstObjectTree[1 + i / oneItemCount].Add(
					new ObjectItemVM() { Name = testData[i + 0], ShortInfo = testData[i + 1], DevType = arrType[i / oneItemCount], ObjStatus = (ComInfoStatus)Enum.Parse(typeof(ComInfoStatus), testData[i + 2]) }
					);
				LstObjectTree[1 + i / oneItemCount].Add(
					new ObjectItemVM() { Name = testData[i + 3], ShortInfo = testData[i + 4], DevType = arrType[i / oneItemCount], ObjStatus = (ComInfoStatus)Enum.Parse(typeof(ComInfoStatus), testData[i + 5]) }
					);
				//LstObjectTree[1 + i / oneItemCount].lstData = new ObservableCollection<object>{
				//	new ObjectItemVM() { Name = testData[i + 0], ShortInfo = testData[i + 1], DevType = arrType[ i / oneItemCount], ObjStatus = (ComInfoStatus)Enum.Parse(typeof(ComInfoStatus), testData[i + 2]) },
				//	new ObjectItemVM() { Name = testData[i + 3], ShortInfo = testData[i + 4], DevType = arrType[ i / oneItemCount], ObjStatus = (ComInfoStatus)Enum.Parse(typeof(ComInfoStatus), testData[i + 5]) }
				//};
			}

			//objectTreeVMCtl.webServer.lstData = new ObservableCollection<ObjectVM>() {
			//	new ObjectVM() { Name = "web服务器", ShortInfo = "离线", DevType= DeviceType.WebServer, ObjStatus = ComInfoStatus.Offline }
			//};

			DevMenuItems.NumMachine = new ObservableCollection<DevMenuItemVM>() { new DevMenuItemVM() { Name = "号牌机1" }, new DevMenuItemVM() { Name = "号牌机2" } };
			DevMenuItems.Laser = new ObservableCollection<DevMenuItemVM>() { new DevMenuItemVM() { Name = "激光1" }, new DevMenuItemVM() { Name = "激光2" } };
			DevMenuItems.Tray = new ObservableCollection<DevMenuItemVM>() { new DevMenuItemVM() { Name = "托盘1" }, new DevMenuItemVM() { Name = "托盘2" } };
			DevMenuItems.Robot = new ObservableCollection<DevMenuItemVM>() { new DevMenuItemVM() { Name = "机械抓手1" }, new DevMenuItemVM() { Name = "机械抓手1" } };
			DevMenuItems.Raster = new ObservableCollection<DevMenuItemVM>() { new DevMenuItemVM() { Name = "光栅1" }, new DevMenuItemVM() { Name = "光栅1" } };
			//objectTreeVMCtl.raster.lstData = new List<ObjectVM>{
			//	new ObjectVM() { Name = "光栅1", ShortInfo = "正常" }, new ObjectVM() { Name = "光栅2", ShortInfo = "正常" }
			//};
			//objectTreeVMCtl.ultrasonic.lstData = new List<ObjectVM>{
			//	new ObjectVM() { Name = "超声波1", ShortInfo = "正常" }, new ObjectVM() { Name = "超声波2", ShortInfo = "正常" }
			//};
			//objectTreeVMCtl.numMachine.lstData = new List<ObjectVM>{
			//	new ObjectVM() { Name = "号牌机1", ShortInfo = "正常" }, new ObjectVM() { Name = "号牌机2", ShortInfo = "正常" }
			//};
			//objectTreeVMCtl.robot.lstData = new List<ObjectVM>{
			//	new ObjectVM() { Name = "机械抓手1", ShortInfo = "正常" }, new ObjectVM() { Name = "机械抓手2", ShortInfo = "正常" }
			//};
			//objectTreeVMCtl.carObject.lstData = new List<ObjectVM>{
			//	new ObjectVM() { Name = "车辆1", ShortInfo = "正常" }, new ObjectVM() { Name = "车辆2", ShortInfo = "正常" }
			//};
			//objectTreeVMCtl.ortherObject.lstData = new List<ObjectVM>{
			//	new ObjectVM() { Name = "其他物体1", ShortInfo = "正常" }, new ObjectVM() { Name = "其他物体2", ShortInfo = "正常" }
			//};

			panel.CentralStatus.setValue(90, null);
			
			panel.WebServer.setValue(10, 2, 1);
			panel.NumMachine.setValue(10, 2, 1);
			panel.Laser.setValue(10, 2, 1);
			panel.Tray.setValue(10, 2, 1);
			panel.Robot.setValue(10, 2, 1);
			panel.Raster.setValue(10, 2, 1);
			panel.Ultrasonic.setValue(10, 2, 1);
			panel.Garage.setValue(10, 2, 1);
			panel.Car.setValue(10, 2, 1);

			//numMachineDetailCtl.name.Data = "号牌机1";
			//numMachineDetailCtl.serNum.Data = "007";
			//DevInfoDetail = numMachineDetailCtl.lstData;
			
			//AlarmInfo = new ObservableCollection<AlarmItemVM>() {
			//	new AlarmItemVM(){ DeviceName = "中控", Info = "CPU忙", Status = AlarmStatus.Info },
			//	new AlarmItemVM(){ DeviceName = "中控", Info = "内存超过90%", Status = AlarmStatus.Warning },
			//	new AlarmItemVM(){ DeviceName = "号牌机1", Info = "异常离线", Status = AlarmStatus.Error }
			//};

			LogInfo = "cpu忙\r\n;内存超过90%";
		}
		
	}
}
